''Elegant ribbon Tutorial
''Licensed Under GPL-v3
''
''
''Get Elegant Ribbon : http://www.prof-uis.com/elegant-ribbon/net-winforms-controls.aspx
''
''A great Thanks to Elegant ribbon for this.
''
''Copyright (c) - 2011-12
''

''File #1
''Form1.VB
''Contains the Code

Imports System.Drawing

''Imports System.Drawing.Font
''Imports System.Drawing.FontStyle
''Imports System.Drawing.Size
''Imports System.Drawing.Points

Public Class Form1

    ''Global Variables
    Public Font_text_Size As Integer
    Public Font_Name As String
    Public Font_Style As FontStyle

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Me.Load
        ''Initialize Global Variables
        Font_text_Size = Val(Font_Size.Text)
        Font_Name = Font_Combo.Text
    End Sub

    ''Open
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles S_Open.Click
        OpenDialog.ShowDialog()
        Dim myStreamReader As System.IO.StreamReader
        Try
            OpenDialog.OpenFile()
            myStreamReader = System.IO.File.OpenText(OpenDialog.FileName)
            Document1.Rtf = myStreamReader.ReadToEnd()
        Catch ex As Exception
        End Try
    End Sub

    ''Save
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles S_Save.Click
        SaveDialog.ShowDialog()

        Dim myStreamWriter As System.IO.StreamWriter
        Try
            myStreamWriter = System.IO.File.AppendText(SaveDialog.FileName)
            myStreamWriter.Write(Document1.Rtf)
            myStreamWriter.Flush()
        Catch ex As Exception
        End Try

    End Sub

    ''Save As
    Private Sub DropDown1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles S_SaveAs.Click
        Save_As_Dialog.ShowDialog()
    End Sub

    ''Exit
    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles S_Exit.Click
        Me.Close()
    End Sub

    ''Hidden Save Quick Access
    Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Save.Click
        SaveDialog.ShowDialog()
    End Sub

    ''Vertical Scroll Bar
    Private Sub VerticalScrollBar1_ValueChanged(ByVal sender As System.Object, ByVal e As Elegant.Ui.ScrollBarValueChangedEventArgs) Handles VerticalScrollBar1.ValueChanged
        Document1.Location = New Point(111, 188 - VerticalScrollBar1.Value)
    End Sub

    ''Zoom
    Private Sub Zoom_ValueChanged(ByVal sender As System.Object, ByVal e As Elegant.Ui.SliderValueChangedEventArgs) Handles Zoom.ValueChanged
        ''Change the Zoom Indicator
        ZoomIndicator.Text = Zoom.Value * 2

        ''Change the Zoom Level
        Document1.Size = New Size((((50 + (Zoom.Value * 2)) / 100) * 572), (((50 + (Zoom.Value * 2)) / 100) * 519))

    End Sub

    ''Zoom Indicator : Default Zoom (100%)
    Private Sub ZoomIndicator_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ZoomIndicator.Click
        Zoom.Value = 50
    End Sub

    ''Font Face
    Private Sub Font_Combo_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Font_Combo.SelectedIndexChanged
        Font_Name = Font_Combo.Text
        Refresh_Doc1(True)
    End Sub

    ''Font Size
    Private Sub Font_Size_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Font_Size.SelectedIndexChanged
        Font_text_Size = Val(Font_Size.Text)
        Refresh_Doc1(True)
    End Sub

    ''Bold
    Private Sub Bold_PressedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bold.PressedChanged
        If Bold.Pressed = True Then
            Font_Style += FontStyle.Bold
        Else
            Font_Style -= FontStyle.Bold
        End If

        Refresh_Doc1(True)
        Document1.Font = New Font(Font_Name, Font_text_Size, Font_Style, GraphicsUnit.Point, CType(0, Byte))



        Document1.Font = New Font(Font_Name, Font_text_Size, Font_Style, GraphicsUnit.Point, CType(0, Byte))
    End Sub

    ''Italic
    Private Sub Italic_PressedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Italic.PressedChanged
        If Italic.Pressed = True Then
            Font_Style += FontStyle.Italic
        Else
            Font_Style -= FontStyle.Italic
        End If

        Refresh_Doc1(True)
    End Sub

    ''Underline
    Private Sub Underline_PressedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Underline.PressedChanged
        If Underline.Pressed = True Then
            Font_Style += FontStyle.Underline
        Else
            Font_Style -= FontStyle.Underline
        End If

        Refresh_Doc1(True)
    End Sub

    ''Function Refresh_Doc1
    Private Sub Refresh_Doc1(ByVal Refresh As Boolean)
        If Refresh = True Then
            Me.Document1.Font = New Font(Font_Name, Font_text_Size, Font_Style, GraphicsUnit.Point, CType(0, Byte))
        End If
    End Sub

    Private Sub Document1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
        ''Words
        Words.Text = "Words : " & (Document1.TextLength)
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        ''Progress Bar
        If ProgressBar1.Value < 100 Then
            ProgressBar1.Value += 1
        End If
    End Sub

    Private Sub StrikeThrough_PressedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StrikeThrough.PressedChanged
        If StrikeThrough.Pressed = True Then
            Font_Style += FontStyle.Strikeout
        Else
            Font_Style -= FontStyle.Strikeout
        End If

        Refresh_Doc1(True)
    End Sub
End Class